﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using Public;

namespace SalomonWebsite.UC
{
    public partial class CatAd : System.Web.UI.UserControl
    {
        #region //封装字段
        private int _parid;

        public int ParPKID
        {
            get { return _parid; }
            set { _parid = value; }
        }
        #endregion

        public int ParID = 0;
        public string AdName = "";
        public string AdDes = "";
        public int AdPKID = 0;
        public string AdImgUrl = "";
        public string ImageWeb = Global.ImageWeb;

        DataTable dtRtn = new DataTable();

        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dtAD = new DataTable();
            dtAD = Bll.CategoryAd.Single(Global.Connection, 1, ParPKID);
            if (dtAD.Rows.Count > 0)
            {
                AdName = dtAD.Rows[0]["AdTitle"].ToString();
                AdDes = dtAD.Rows[0]["Description"].ToString();
                AdImgUrl = dtAD.Rows[0]["ImgURL"].ToString();
                AdPKID = Convert.ToInt32(dtAD.Rows[0]["PKID"]);
            }
            else
            {
                this.PlusAD.Visible = false;
            }
            
        }

       
        protected void GetCatData(int parID, DataTable dtCat)
        {
            DataRow[] drs = dtCat.Select(" [PKID] = " + parID);

            for (int i = 0; i < drs.Length; i++)
            {
                if (Convert.ToInt32(drs[i]["CatRank"]) == 1)
                {
                    ParID = Convert.ToInt32(drs[i]["PKID"]);
                }
                else
                {
                    GetCatData(Convert.ToInt32(drs[i]["ParID"]), dtCat);
                }
            }
        }
    }
}